1. /* smmoutfl.cpp by K.Tsuru */
  2. // function ID = 004 DRADIX
  3. /************************
  4. SNManager class
  5. Change the output stream.
  6. *************************/
  7. #ifndef SN_H
  8. #include "sn.h"
  9. #endif
  10. static FILE* openStream = NULL;
  11. static int open = -1;
  12. void SNManager::CloseFile(){
  13. if(open > 0) SNManager::OutPutFile(NULL);
  14. }
  15. // function ID = 004
  16. // a static function of SNManager class
  17. FILE* SNManager::OutPutFile(const char* fname, bool ovw){
  18. if(fname == NULL){
  19. if(stream == openStream) fclose(openStream);
  20. stream = stdout; open = 0;
  21. return stream;
  22. }
  23. if( (ovw == false) && (openStream = fopen(fname,"rt")) != NULL){
  24. fprintf(stderr, "\aFile \"%s\" already exists. Over write ?(y/n) ", fname);
  25. if( YesOrNo() == 0){
  26. fclose(openStream);
  27. stream = stdout; open = 0;
  28. fprintf(stderr, "Do you continue ?(y/n) ");
  29. if(YesOrNo() == 0) exit(EXIT_FAILURE);
  30. return stream;
  31. }
  32. }
  33. openStream = fopen(fname,"wt");
  34. if(openStream == NULL){
  35. fprintf(stderr, "Cannot open output file %s.\n", fname);
  36. exit(EXIT_FAILURE);
  37. } else {
  38. open = 1;
  39. }
  40. stream = openStream;
  41. return stream;
  42. }

smmoutfl.cpp : last modifiled at 2017/07/16 16:00:03(1,144 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).